#ifndef RAW_DATA_H
#define RAW_DATA_H

#include <cstring>
#include <string>

#define MAX_NAME_SIZE 100

namespace caviz
{
#pragma pack(1)
  struct RawDataHead
  {
    RawDataHead()
    {
      clear();
    }

    void clear()
    {
      memset(name, 0, MAX_NAME_SIZE);
      size = 0;
      timestamp = 0.0;
    }
    char name[MAX_NAME_SIZE];
    size_t size;
    double timestamp;
  };
#pragma pack()

  /**
   * @brief RawData 是在 MetaData的基础上添加了数据头，用以数据存储、读取
   *
   */
  class RawData
  {
  public:
    RawData(const std::string &raw_data);
    RawData(const std::string &name, double timestamp,
            const std::string &meta_data);
    ~RawData() {}
    std::string metaData() { return meta_data_; }
    std::string name() { return name_; }
    std::string rawData() { return raw_data_; }

    static void GetRawDataHeader(std::string &header, const std::string &name, double timestamp, const std::string &meta_data);

  private:
    std::string name_;
    std::string raw_data_;
    std::string meta_data_;
    RawDataHead head_;

    int headSize_ = sizeof(RawDataHead);
  };

} // end namespace caviz

#endif // RAW_DATA_H
